import http from '@/http'

export default {

  /**
   * 用户注册
   *
   * @param username
   * @param password
   * @param conPassword
   * @param email
   * @returns {*}
   */
  reg(username, password, conPassword, email) {
    return http({
      url: '/api/auth/user/reg',
      method: 'POST',
      data: {
        username,
        password,
        conPassword,
        email
      },
      loading: true
    })
  },

  /**
   * 激活
   *
   * @param token
   * @returns {*}
   */
  active(token) {
    return http({
      url: '/api/active/' + token,
      method: 'GET',
      loading: true
    })
  },

  /**
   * 用户登陆
   *
   * @param username
   * @param password
   * @returns {*}
   */
  login(username, password) {
    return http({
      url: '/api/auth/user/login',
      method: 'POST',
      data: {
        username,
        password
      },
      loading: true
    })
  },

  /**
   * 注销登录
   *
   * @returns {*}
   */
  logout() {
    return http({
      url: '/api/user/logout',
      method: 'POST',
      loading: true
    })
  },

  /**
   * 获取当前Token的用户信息
   *
   * @returns {*}
   */
  getUserInfo() {
    return http({
      url: '/api/user/getCurrentUserInfo',
      method: 'GET',
      loading: false
    })
  },

  /**
   * 更新密码
   *
   * @returns {*}
   */
  updatePassword(data) {
    return http({
      url: '/api/user/updatePassword',
      method: 'POST',
      data: data,
      loading: true
    })
  },

  /**
   * 获取仪表盘数据
   *
   * @returns {*}
   */
  getDashboardPageInfo() {
    return http({
      url: '/api/user/dashboard',
      method: 'GET',
      loading: false
    })
  },
  /**
   * 获取支出列表
   *
   * @param page
   * @param size
   * @param data
   * @returns {*}
   */
  getSpendingList(page, size, data) {
    return http({
      url: '/api/user/spending/getList/' + page + '/' + size,
      method: 'POST',
      data,
      loading: false
    })
  },

  /**
   * 添加支出
   *
   * @param typeId 支出类型ID
   * @param amount 支出金额
   * @param note 备注
   * @returns {*}
   */
  addSpending(typeId, amount, note) {
    return http({
      url: '/api/user/spending/add',
      method: 'POST',
      data: {
        typeId,
        amount,
        note
      },
      loading: true
    })
  },

  /**
   * 获取支出类型列表
   *
   * @returns {*}
   */
  getTypeList() {
    return http({
      url: '/api/user/type/getList',
      method: 'GET',
      loading: true
    })
  }
}